<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="mac5855.app.dao.CategoriaDAO"%>
<%@page import="mac5855.app.models.Categoria"%>
<%@page import="mac5855.app.dao.DAOFactory"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="mac5855.app.dao.PerguntaDAO"%>
<%@page import="mac5855.app.models.Pergunta"%>
<%@page import="java.text.NumberFormat"%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="/sistemaperguntaresposta/css/style.css" media="all" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
</head>

<body onload="javascript: iniciaComet2();">

<body>

<div id="centralizer">
	<jsp:include page="/header.jsp"></jsp:include>
    
    <div id="home" class="content">
    	<div class="question_box">
    		<form action="/sistemaperguntaresposta/controller?business=PerguntaController" method="post">
	        	<h3>Nova Pergunta</h3>
	            <div class="dashed_separator"></div>
	        	<label>Pergunta:</label>
	            <textarea name="titulo"></textarea>
	            <div class="cleaner separator"></div>
	            <label>Categoria:</label>
	            <select name="categoria_id">
						<% CategoriaDAO dao = DAOFactory.getDAOFactory(DAOFactory.JDBC).getCategoriaDAO();
							Categoria[] categorias = dao.findAll();
							for (Categoria categoria : categorias ) { %>
							<option value="<%= categoria.getId() %>"><%= categoria.getNome() %></option>
						<% } %>
				</select>
	            <div class="cleaner dashed_separator"></div>
	            <div class="action_buttons">
	            	<input type="submit" value="Criar" />
	            </div>
            </form>
        </div>
        
        <div class="separator"></div>
        
        <div class="category_box">
        	<h3>Categorias</h3>
            <div class="dashed_separator"></div>
        	<ul>
        		<% for (Categoria categoria : categorias ) { %>
					<li><%= categoria.getNome() %></li>        		
        		<% } %>
            </ul>
        </div>
        
        <div class="search_box">
        	<form action="/sistemaperguntaresposta/controller?business=PerguntaController" method="post">
	        	<h3>Buscar uma Pergunta</h3>
	            <div class="dashed_separator"></div>
	            <input type="hidden" name="action" value="search"/>
	           	<input type="text" class="input_text" name="search"/>
	           	<input type="submit" class="input_button" value="Buscar" />
           	</form>
        </div>
        
        <div class="question_list_box">
            <h3>Perguntas Recentes</h3>
            <div class="dashed_separator"></div>
        	<ul id="perguntas">
        	    </ul>
        </div>
        
        <div class="cleaner"></div>
    </div>
    
    <div class="footer">
    </div>
</div>

</body>
</html>
